﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TanmiaGrp.Basis.Core;

namespace TanmiaGrp.GeneralLedger.Core
{
    public partial class Group : BusinessObject, IEquatable<Group>
    {
        public static readonly Group Comparer = new Group { GroupID = -2 };

        #region Private Members
        private int groupID;
        private string groupName;
        private bool isEnable;
        private string notes;

        #endregion

        #region Public Properties

        public int GroupID
        {
            get { return groupID; }
            set
            {
                if (groupID != value)
                {
                    groupID = value;
                    RaisePropertyChanged(() => GroupID);
                }
            }
        }

        [Required]
        [MaxLength(64)]
        public string GroupName
        {
            get { return groupName; }
            set
            {
                if (groupName != value)
                {
                    groupName = value;
                    RaisePropertyChanged(() => GroupName);
                }
            }
        }

        public bool IsEnabled
        {
            get { return isEnable; }
            set
            {
                if (isEnable != value)
                {
                    isEnable = value;
                    RaisePropertyChanged(() => IsEnabled);
                }
            }
        }

        [MaxLength(255)]
        public string Notes
        {
            get { return notes; }
            set
            {
                if (notes != value)
                {
                    notes = value;
                    RaisePropertyChanged(() => Notes);
                }
            }
        }

        #endregion

        public override bool Equals(object obj)
        {
            Group paramGroup = obj as Group;
            if (paramGroup == null) return false;

            if (!base.Equals(obj)) return false;

            if (!GroupID.Equals(paramGroup.GroupID)) return false;

            return true;
        }

        #region IEquatable<Group> Members

        public bool Equals(Group other)
        {
            if (other == null) return false;
            if (!other.GroupID.Equals(GroupID)) return false;
            return true;
        }

        #endregion
    }
}
